package com.lollipop.synthential.json;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Author: J.K
 * @Date: 2020-12-04 16:25
 * @Description:
 */
public class dfda {
    public static void main(String args[]) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());

        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String nowDate = dateFormat.format(new Date());
        System.out.println(nowDate);

        calendar.add(Calendar.DATE, -3);
        Date lastDate = calendar.getTime();
        String lastDates = dateFormat.format(lastDate);

        System.out.println(lastDates);


        String dateTime = dateFormat.format(new Date());
        String dateTimes = dateFormat.format(lastDate);

        StringBuilder builder = new StringBuilder(nowDate);
        StringBuilder builder2 = new StringBuilder(dateTimes);

//        StringBuilder builder = new StringBuilder(dateTime);
        builder.replace(11, 19, "00:00:00");
        builder2.replace(11, 19, "00:00:00");
        String year = dateTime.substring(0, 4);
        String mo = dateTime.substring(5, 7);
        String day = dateTime.substring(8, 10);
//        String hour=dateTime.substring(11);
        String hour = dateTime.substring(0, 13);
        System.out.println(year);
        System.out.println(mo);
        System.out.println(day);
        System.out.println(hour);
        System.out.println(builder);
        System.out.println(builder2);
    }
}
